using System;
using System.Collections.Generic;
using System.Text;

namespace MicrosoftFrance.MCS.EPM2007
{
    class PSIAdmin
    {
        public static void ReadStatusingSettings()
        {
            AdminWS.StatusingSettingsDataSet ssDS = Program.admin.ReadStatusingSettings();
        }

        public static AdminWS.TimePeriodDataSet ReadOpenPeriods()
        {
            return Program.admin.ReadPeriods(AdminWS.PeriodState.Open);
        }

        public static Guid GetTSPeriodUid(int periodNumber)
        {
            AdminWS.TimePeriodDataSet timePeriodDs = ReadOpenPeriods();

            for (int i = 0; i < timePeriodDs.TimePeriods.Count; i++)
            {
                if (string.Compare(periodNumber.ToString(), timePeriodDs.TimePeriods[i].WPRD_NAME, true) == 0)
                    return timePeriodDs.TimePeriods[i].WPRD_UID;
            }
            return Guid.Empty;
        }

        public static Guid GetTSPeriodUid(string periodName)
        {
            AdminWS.TimePeriodDataSet timePeriodDs = ReadOpenPeriods();

            for (int i = 0; i < timePeriodDs.TimePeriods.Count; i++)
            {
                if (string.Compare(periodName, timePeriodDs.TimePeriods[i].WPRD_NAME, true) == 0)
                    return timePeriodDs.TimePeriods[i].WPRD_UID;
            }
            return Guid.Empty;
        }

        public static string GetTSPeriodName(Guid periodUid)
        {
            AdminWS.TimePeriodDataSet timePeriodDs = ReadOpenPeriods();

            for (int i = 0; i < timePeriodDs.TimePeriods.Count; i++)
            {
                if (periodUid == timePeriodDs.TimePeriods[i].WPRD_UID)
                    return timePeriodDs.TimePeriods[i].WPRD_NAME;
            }
            return string.Empty;
        }
    }
}
